<!DOCTYPE html>
<html>
<head>
<title>登 录</title>
<meta charset="utf-8" >
<meta name="renderer" content="webkit">
<meta name="author" content="XYB" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="format-detection" content="telphone=no, email=no"/>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="viewport" content="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no">
<link rel="stylesheet" href="../../static/css/bootstrap.min.css">
<link rel="stylesheet" href="../../static/css/init.css">
<link rel="stylesheet" href="../../static/css/common.css">
<link rel="stylesheet" href="../../static/css/user/login.css">
<link rel="icon" href="../../static/images/favicon.ico" type="image/x-icon">
</head>
<body>
    <div class="allwarp">
		<div class="main-Content relative">
	    	<div class="login-page">
	    		<img class="login-badgeimg" src="../../static/images/user/1.jpg"/>
	    		<div class="form">
	    			<form class="login-form">
	    				<div class="title mb-25 text-center f-18 c-333">登 录</div>
						<input type="text" placeholder="用户名" maxlength="11" id="r_username" />
						<input type="password" placeholder="密码" maxlength="15" id="r_password" />
						<a class="float-left" href="javascript:;" onclick="login()">登 录</a>
						<a href="register.html" class="float-right">注 册</a>
					</form>
	    		</div>
	    	</div>
		</div>
    </div>
</body>
<script src="../../static/js/util/jquery-1.9.1.min.js"></script>
<script src="../../static/js/util/bootstrap.min.js"></script>
<script src="../../static/js/util/template.js"></script>
<script id="template" type="text/html"></script>
<script src="../../static/js/commonJS/interface.js"></script>
<script src="../../static/js/commonJS/common.js"></script>
<script>
function login(){

	var username = $("#r_username").val();
    var password = $("#r_password").val();

    if(username==""){
		$.message("请输入用户名");
		return;
	}
    if(password==""){
        $.message("请输入密码");
        return;
    }
    $.ajax({
        url: login_interface,
        type:'post',
        dataType:'json',
		xhrFields:{
		withCredentials:true
		},
		crossDomain:true,
        data:{
            "username":username,
            "password":password
        },
        success: function(data) {
            if(data.code==200){
                if(data.data.user_type==4){
					/**
					 * 1代表游客或者学生，也就是普通用户
                     2代表老师
                     3代表课程负责人
                     4代表系统管理员
					 * **/
					location.href = '../admin/index.html#/admin';
				}else if(data.data.user_type==3){location.href = '../index/index.html';}
					else if(data.data.user_type==2){location.href = '../index/index.html';}
					else if(data.data.user_type==1){location.href='../index/index.html';}
            }else{
                $.message(data.msg);
            }
        },
        error: function () {
            $.message("链接超时，请刷新...");
        }
    });
}
</script>
</html>